// $ANTLR 3.1.1 /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g 2009-01-29 12:01:23

package org.six11.olive3.net;

import java.util.Map;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class Olive3Parser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "KeyVal", "Message", "OliveStream", "Optional", "Params", "Required", "Statement", "Statements", "ID", "NUM", "STR_CHARS", "INT", "LETTER", "ESC_SEQ", "UNI_ESC", "OCT_ESC", "HEX_DIGIT", "WS", "NL", "'{'", "'}'", "'('", "')'", "'='"
    };
    public static final int LETTER=16;
    public static final int T__23=23;
    public static final int Message=5;
    public static final int WS=21;
    public static final int Statement=10;
    public static final int OCT_ESC=19;
    public static final int Params=8;
    public static final int ESC_SEQ=17;
    public static final int UNI_ESC=18;
    public static final int NL=22;
    public static final int OliveStream=6;
    public static final int INT=15;
    public static final int EOF=-1;
    public static final int T__27=27;
    public static final int NUM=13;
    public static final int T__24=24;
    public static final int Statements=11;
    public static final int STR_CHARS=14;
    public static final int T__26=26;
    public static final int Required=9;
    public static final int T__25=25;
    public static final int HEX_DIGIT=20;
    public static final int Optional=7;
    public static final int KeyVal=4;
    public static final int ID=12;

    // delegates
    // delegators


        public Olive3Parser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public Olive3Parser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return Olive3Parser.tokenNames; }
    public String getGrammarFileName() { return "/Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g"; }


      Map<String, String> params;
      
      public void setParams(Map<String, String> params) {
        this.params = params;
      }


    public static class olive_stream_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "olive_stream"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:39:1: olive_stream : ( block )* -> ^( OliveStream ( block )* ) ;
    public final Olive3Parser.olive_stream_return olive_stream() throws RecognitionException {
        Olive3Parser.olive_stream_return retval = new Olive3Parser.olive_stream_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Olive3Parser.block_return block1 = null;


        RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:40:2: ( ( block )* -> ^( OliveStream ( block )* ) )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:40:4: ( block )*
            {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:40:4: ( block )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==ID) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:40:4: block
            	    {
            	    pushFollow(FOLLOW_block_in_olive_stream100);
            	    block1=block();

            	    state._fsp--;

            	    stream_block.add(block1.getTree());

            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);



            // AST REWRITE
            // elements: block
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 41:3: -> ^( OliveStream ( block )* )
            {
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:41:6: ^( OliveStream ( block )* )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(OliveStream, "OliveStream"), root_1);

                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:41:20: ( block )*
                while ( stream_block.hasNext() ) {
                    adaptor.addChild(root_1, stream_block.nextTree());

                }
                stream_block.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "olive_stream"

    public static class block_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "block"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:44:1: block : ID assignments '{' statements '}' -> ^( Message ID assignments statements ) ;
    public final Olive3Parser.block_return block() throws RecognitionException {
        Olive3Parser.block_return retval = new Olive3Parser.block_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token ID2=null;
        Token char_literal4=null;
        Token char_literal6=null;
        Olive3Parser.assignments_return assignments3 = null;

        Olive3Parser.statements_return statements5 = null;


        CommonTree ID2_tree=null;
        CommonTree char_literal4_tree=null;
        CommonTree char_literal6_tree=null;
        RewriteRuleTokenStream stream_24=new RewriteRuleTokenStream(adaptor,"token 24");
        RewriteRuleTokenStream stream_23=new RewriteRuleTokenStream(adaptor,"token 23");
        RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleSubtreeStream stream_assignments=new RewriteRuleSubtreeStream(adaptor,"rule assignments");
        RewriteRuleSubtreeStream stream_statements=new RewriteRuleSubtreeStream(adaptor,"rule statements");
        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:45:2: ( ID assignments '{' statements '}' -> ^( Message ID assignments statements ) )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:45:4: ID assignments '{' statements '}'
            {
            ID2=(Token)match(input,ID,FOLLOW_ID_in_block124);  
            stream_ID.add(ID2);

            pushFollow(FOLLOW_assignments_in_block126);
            assignments3=assignments();

            state._fsp--;

            stream_assignments.add(assignments3.getTree());
            char_literal4=(Token)match(input,23,FOLLOW_23_in_block128);  
            stream_23.add(char_literal4);

            pushFollow(FOLLOW_statements_in_block130);
            statements5=statements();

            state._fsp--;

            stream_statements.add(statements5.getTree());
            char_literal6=(Token)match(input,24,FOLLOW_24_in_block132);  
            stream_24.add(char_literal6);



            // AST REWRITE
            // elements: ID, assignments, statements
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 46:3: -> ^( Message ID assignments statements )
            {
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:46:6: ^( Message ID assignments statements )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(Message, "Message"), root_1);

                adaptor.addChild(root_1, stream_ID.nextNode());
                adaptor.addChild(root_1, stream_assignments.nextTree());
                adaptor.addChild(root_1, stream_statements.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "block"

    public static class assignments_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "assignments"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:49:1: assignments : '(' ( assignment )* ')' -> ^( Params ( assignment )* ) ;
    public final Olive3Parser.assignments_return assignments() throws RecognitionException {
        Olive3Parser.assignments_return retval = new Olive3Parser.assignments_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token char_literal7=null;
        Token char_literal9=null;
        Olive3Parser.assignment_return assignment8 = null;


        CommonTree char_literal7_tree=null;
        CommonTree char_literal9_tree=null;
        RewriteRuleTokenStream stream_26=new RewriteRuleTokenStream(adaptor,"token 26");
        RewriteRuleTokenStream stream_25=new RewriteRuleTokenStream(adaptor,"token 25");
        RewriteRuleSubtreeStream stream_assignment=new RewriteRuleSubtreeStream(adaptor,"rule assignment");
        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:50:2: ( '(' ( assignment )* ')' -> ^( Params ( assignment )* ) )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:50:4: '(' ( assignment )* ')'
            {
            char_literal7=(Token)match(input,25,FOLLOW_25_in_assignments157);  
            stream_25.add(char_literal7);

            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:50:8: ( assignment )*
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==ID) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:50:8: assignment
            	    {
            	    pushFollow(FOLLOW_assignment_in_assignments159);
            	    assignment8=assignment();

            	    state._fsp--;

            	    stream_assignment.add(assignment8.getTree());

            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);

            char_literal9=(Token)match(input,26,FOLLOW_26_in_assignments162);  
            stream_26.add(char_literal9);



            // AST REWRITE
            // elements: assignment
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 51:3: -> ^( Params ( assignment )* )
            {
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:51:6: ^( Params ( assignment )* )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(Params, "Params"), root_1);

                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:51:15: ( assignment )*
                while ( stream_assignment.hasNext() ) {
                    adaptor.addChild(root_1, stream_assignment.nextTree());

                }
                stream_assignment.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "assignments"

    public static class assignment_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "assignment"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:54:1: assignment : ID '=' literal -> ^( KeyVal ID literal ) ;
    public final Olive3Parser.assignment_return assignment() throws RecognitionException {
        Olive3Parser.assignment_return retval = new Olive3Parser.assignment_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token ID10=null;
        Token char_literal11=null;
        Olive3Parser.literal_return literal12 = null;


        CommonTree ID10_tree=null;
        CommonTree char_literal11_tree=null;
        RewriteRuleTokenStream stream_27=new RewriteRuleTokenStream(adaptor,"token 27");
        RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleSubtreeStream stream_literal=new RewriteRuleSubtreeStream(adaptor,"rule literal");
        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:55:2: ( ID '=' literal -> ^( KeyVal ID literal ) )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:55:4: ID '=' literal
            {
            ID10=(Token)match(input,ID,FOLLOW_ID_in_assignment184);  
            stream_ID.add(ID10);

            char_literal11=(Token)match(input,27,FOLLOW_27_in_assignment186);  
            stream_27.add(char_literal11);

            pushFollow(FOLLOW_literal_in_assignment188);
            literal12=literal();

            state._fsp--;

            stream_literal.add(literal12.getTree());


            // AST REWRITE
            // elements: literal, ID
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 56:3: -> ^( KeyVal ID literal )
            {
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:56:6: ^( KeyVal ID literal )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(KeyVal, "KeyVal"), root_1);

                adaptor.addChild(root_1, stream_ID.nextNode());
                adaptor.addChild(root_1, stream_literal.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "assignment"

    public static class statements_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "statements"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:59:1: statements : ( statement )* -> ^( Statements ( statement )* ) ;
    public final Olive3Parser.statements_return statements() throws RecognitionException {
        Olive3Parser.statements_return retval = new Olive3Parser.statements_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Olive3Parser.statement_return statement13 = null;


        RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:60:2: ( ( statement )* -> ^( Statements ( statement )* ) )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:60:4: ( statement )*
            {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:60:4: ( statement )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==ID) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:60:4: statement
            	    {
            	    pushFollow(FOLLOW_statement_in_statements211);
            	    statement13=statement();

            	    state._fsp--;

            	    stream_statement.add(statement13.getTree());

            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);



            // AST REWRITE
            // elements: statement
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 61:3: -> ^( Statements ( statement )* )
            {
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:61:6: ^( Statements ( statement )* )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(Statements, "Statements"), root_1);

                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:61:19: ( statement )*
                while ( stream_statement.hasNext() ) {
                    adaptor.addChild(root_1, stream_statement.nextTree());

                }
                stream_statement.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "statements"

    public static class statement_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "statement"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:64:1: statement : type= ID (required+= literal )* (optional+= assignment )* -> ^( Statement $type ^( Required ( $required)* ) ^( Optional ( $optional)* ) ) ;
    public final Olive3Parser.statement_return statement() throws RecognitionException {
        Olive3Parser.statement_return retval = new Olive3Parser.statement_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token type=null;
        List list_required=null;
        List list_optional=null;
        RuleReturnScope required = null;
        RuleReturnScope optional = null;
        CommonTree type_tree=null;
        RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleSubtreeStream stream_assignment=new RewriteRuleSubtreeStream(adaptor,"rule assignment");
        RewriteRuleSubtreeStream stream_literal=new RewriteRuleSubtreeStream(adaptor,"rule literal");
        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:65:2: (type= ID (required+= literal )* (optional+= assignment )* -> ^( Statement $type ^( Required ( $required)* ) ^( Optional ( $optional)* ) ) )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:65:4: type= ID (required+= literal )* (optional+= assignment )*
            {
            type=(Token)match(input,ID,FOLLOW_ID_in_statement237);  
            stream_ID.add(type);

            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:65:20: (required+= literal )*
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( ((LA4_0>=NUM && LA4_0<=STR_CHARS)) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:65:20: required+= literal
            	    {
            	    pushFollow(FOLLOW_literal_in_statement241);
            	    required=literal();

            	    state._fsp--;

            	    stream_literal.add(required.getTree());
            	    if (list_required==null) list_required=new ArrayList();
            	    list_required.add(required.getTree());


            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);

            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:65:39: (optional+= assignment )*
            loop5:
            do {
                int alt5=2;
                int LA5_0 = input.LA(1);

                if ( (LA5_0==ID) ) {
                    int LA5_2 = input.LA(2);

                    if ( (LA5_2==27) ) {
                        alt5=1;
                    }


                }


                switch (alt5) {
            	case 1 :
            	    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:65:39: optional+= assignment
            	    {
            	    pushFollow(FOLLOW_assignment_in_statement246);
            	    optional=assignment();

            	    state._fsp--;

            	    stream_assignment.add(optional.getTree());
            	    if (list_optional==null) list_optional=new ArrayList();
            	    list_optional.add(optional.getTree());


            	    }
            	    break;

            	default :
            	    break loop5;
                }
            } while (true);



            // AST REWRITE
            // elements: type, optional, required
            // token labels: type
            // rule labels: retval
            // token list labels: 
            // rule list labels: optional, required
            retval.tree = root_0;
            RewriteRuleTokenStream stream_type=new RewriteRuleTokenStream(adaptor,"token type",type);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_optional=new RewriteRuleSubtreeStream(adaptor,"token optional",list_optional);
            RewriteRuleSubtreeStream stream_required=new RewriteRuleSubtreeStream(adaptor,"token required",list_required);
            root_0 = (CommonTree)adaptor.nil();
            // 66:3: -> ^( Statement $type ^( Required ( $required)* ) ^( Optional ( $optional)* ) )
            {
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:66:6: ^( Statement $type ^( Required ( $required)* ) ^( Optional ( $optional)* ) )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(Statement, "Statement"), root_1);

                adaptor.addChild(root_1, stream_type.nextNode());
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:66:24: ^( Required ( $required)* )
                {
                CommonTree root_2 = (CommonTree)adaptor.nil();
                root_2 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(Required, "Required"), root_2);

                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:66:35: ( $required)*
                while ( stream_required.hasNext() ) {
                    adaptor.addChild(root_2, stream_required.nextTree());

                }
                stream_required.reset();

                adaptor.addChild(root_1, root_2);
                }
                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:66:47: ^( Optional ( $optional)* )
                {
                CommonTree root_2 = (CommonTree)adaptor.nil();
                root_2 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(Optional, "Optional"), root_2);

                // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:66:58: ( $optional)*
                while ( stream_optional.hasNext() ) {
                    adaptor.addChild(root_2, stream_optional.nextTree());

                }
                stream_optional.reset();

                adaptor.addChild(root_1, root_2);
                }

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "statement"

    public static class literal_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "literal"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:69:1: literal : ( literalNum | literalString );
    public final Olive3Parser.literal_return literal() throws RecognitionException {
        Olive3Parser.literal_return retval = new Olive3Parser.literal_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Olive3Parser.literalNum_return literalNum14 = null;

        Olive3Parser.literalString_return literalString15 = null;



        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:70:6: ( literalNum | literalString )
            int alt6=2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0==NUM) ) {
                alt6=1;
            }
            else if ( (LA6_0==STR_CHARS) ) {
                alt6=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 6, 0, input);

                throw nvae;
            }
            switch (alt6) {
                case 1 :
                    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:70:8: literalNum
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_literalNum_in_literal291);
                    literalNum14=literalNum();

                    state._fsp--;

                    adaptor.addChild(root_0, literalNum14.getTree());

                    }
                    break;
                case 2 :
                    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:71:8: literalString
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_literalString_in_literal300);
                    literalString15=literalString();

                    state._fsp--;

                    adaptor.addChild(root_0, literalString15.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "literal"

    public static class literalNum_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "literalNum"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:74:1: literalNum : NUM ;
    public final Olive3Parser.literalNum_return literalNum() throws RecognitionException {
        Olive3Parser.literalNum_return retval = new Olive3Parser.literalNum_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token NUM16=null;

        CommonTree NUM16_tree=null;

        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:75:2: ( NUM )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:75:4: NUM
            {
            root_0 = (CommonTree)adaptor.nil();

            NUM16=(Token)match(input,NUM,FOLLOW_NUM_in_literalNum311); 
            NUM16_tree = (CommonTree)adaptor.create(NUM16);
            adaptor.addChild(root_0, NUM16_tree);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "literalNum"

    public static class literalString_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "literalString"
    // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:78:1: literalString : STR_CHARS ;
    public final Olive3Parser.literalString_return literalString() throws RecognitionException {
        Olive3Parser.literalString_return retval = new Olive3Parser.literalString_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token STR_CHARS17=null;

        CommonTree STR_CHARS17_tree=null;

        try {
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:79:2: ( STR_CHARS )
            // /Users/johnsogg/Projects/sketching-games/src/org/six11/olive3/net/Olive3.g:79:4: STR_CHARS
            {
            root_0 = (CommonTree)adaptor.nil();

            STR_CHARS17=(Token)match(input,STR_CHARS,FOLLOW_STR_CHARS_in_literalString322); 
            STR_CHARS17_tree = (CommonTree)adaptor.create(STR_CHARS17);
            adaptor.addChild(root_0, STR_CHARS17_tree);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "literalString"

    // Delegated rules


 

    public static final BitSet FOLLOW_block_in_olive_stream100 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_ID_in_block124 = new BitSet(new long[]{0x0000000002000000L});
    public static final BitSet FOLLOW_assignments_in_block126 = new BitSet(new long[]{0x0000000000800000L});
    public static final BitSet FOLLOW_23_in_block128 = new BitSet(new long[]{0x0000000001001000L});
    public static final BitSet FOLLOW_statements_in_block130 = new BitSet(new long[]{0x0000000001000000L});
    public static final BitSet FOLLOW_24_in_block132 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_25_in_assignments157 = new BitSet(new long[]{0x0000000004001000L});
    public static final BitSet FOLLOW_assignment_in_assignments159 = new BitSet(new long[]{0x0000000004001000L});
    public static final BitSet FOLLOW_26_in_assignments162 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_assignment184 = new BitSet(new long[]{0x0000000008000000L});
    public static final BitSet FOLLOW_27_in_assignment186 = new BitSet(new long[]{0x0000000000006000L});
    public static final BitSet FOLLOW_literal_in_assignment188 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_statement_in_statements211 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_ID_in_statement237 = new BitSet(new long[]{0x0000000000007002L});
    public static final BitSet FOLLOW_literal_in_statement241 = new BitSet(new long[]{0x0000000000007002L});
    public static final BitSet FOLLOW_assignment_in_statement246 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_literalNum_in_literal291 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_literalString_in_literal300 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_NUM_in_literalNum311 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_STR_CHARS_in_literalString322 = new BitSet(new long[]{0x0000000000000002L});

}